/***********************************************************************
	filename: 	DaterGroupManager.h
	created:	6/5/2012
	author:		4Ys
	
	purpose:	Defines the interface for the GroupManager object
*************************************************************************/
#ifndef _DaterGroupManager_h_
#define _DaterGroupManager_h_

#include "DaterSingleton.h"
#include "DaterGroup.h"
#include "DaterIteratorBase.h"

#include <map>
#include <string>

namespace Dater
{
	class GroupManager : public Singleton <GroupManager>
	{
	public:
		/*!
		\brief
			Constructs a new GroupManager object.
		*/
		GroupManager(void);
		
		/*!
	    \brief
			Destructor for GroupManager objects

			This will properly destroy all remaining Group objects.  
		*/
		~GroupManager(void);
		
		/*!
		\brief
			Creates a new Group object and gives it the specified unique name.

		\param name
			String that holds a unique name that is to be given to the new Group. The name cannot be empty.

		\param gID
			The gID of the user who created this Group.

		\return
			Pointer to the newly created Event object.
		*/
		Group* addGroup(const std::string& name,const std::string& type,const std::string& decription, int gID, const Time& createTime
			, int creatorID);
		
		/*!
		\brief
			Destroy the specified Group object.

		\param theGroup	
			String containing the name of the Group object to be destroyed.  If an Group is not recognised, nothing happens.

		\return
			Nothing.
		*/
		void destroyGroup(int groupID);
				
		/*!
		\brief
			Destroys all Window objects within the system

		\return
			Nothing
		*/
		void destroyAllGroups(void);

		/*!
		\brief
			Return a pointer to the specified Group object.

		\param name
			String holding the name of the Group object to be returned.

		\return
			Pointer to the Group object with the name.
		*/
		Group* getGroup(int groupID) const;
		
		/*!
		\brief
			Examines the list of Group objects to see if one exists with the given name

		\param name
			String holding the name of the Group object to look for.

		\return
			true if an Group object was found with a name matching the name.  
			false if no matching Group object was found.
		*/
		bool isGroupPresent(int groupID) const;

	private:
		typedef std::map<int, Group*> GroupRegistry;	//!< Type used to implement registry of Group objects

		GroupRegistry _groupRegistry;	//!< The container that forms the Group registry

		//unsigned long _uid_counter;		//!< Counter used to generate unique event names.

	public:
		typedef ConstBaseIterator< GroupRegistry > GroupIterator;	

		/*!
		\brief
			Return a GroupManager::GroupIterator object to iterate over the currently defined Groups.
		*/
		GroupIterator getIterator(void) const;

	};
}

#endif